/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package cl.zeke.pizzastore.jdbc.dao;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 *
 * @author taller
 */
@Repository
public class TestDao {
    
    @Autowired
    @Qualifier("dataSource2")
    private DataSource ds;
    
    @Autowired
    private JdbcTemplate jdbcTemplate;
    
    public void prueba() {
        Connection c = null;
        try {
               c = ds.getConnection();
        } catch (Exception ex) {
            Logger.getLogger(TestDao.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            try {
                c.close();
            } catch (SQLException ex) {
                Logger.getLogger(TestDao.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    
    public void prueba2() {
        try(Connection c = ds.getConnection()) {
            
        } catch (Exception ex) {
            Logger.getLogger(TestDao.class.getName()).log(Level.SEVERE, null, ex);
        } 
    }
    
    public void prueba3() {
        //jdbcTemplate.query
    }
    
    
}
